{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Interpolation\n",
    "\n",
    "This notebook uses the [Interpolations](https://github.com/JuliaMath/Interpolations.jl) package. As an alternative, consider [Dierckx](https://github.com/kbarbary/Dierckx.jl)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Load Packages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "printyellow (generic function with 1 method)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "using Dates, Interpolations\n",
    "\n",
    "include(\"printmat.jl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "using Plots\n",
    "\n",
    "#pyplot(size=(600,400))    \n",
    "gr(size=(480,320))\n",
    "default(fmt = :svg)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# Interpolation of y = f(x)\n",
    "\n",
    "Interpolations are particularly useful when we repeatedly want to evaluate a function $f(x)$, or when we only know $f(x)$ for a grid of $x$ values but we have strong beliefs that the function is pretty smooth. We then do something like this:\n",
    "\n",
    "1. Calculate $f(x)$ values for a grid of $x$. This creates a \"look-up\" table.\n",
    "2. Replace the expensive calculations of $f(x_i)$ by interpolating $f(x_i)$ from the \"look-up\" table."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Some Values to Be Interpolated\n",
    "\n",
    "As a simple illustration, we interpolate the sine function. (In practice, the interpolation technique is typically applied to more complicated functions.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"480\" height=\"320\" viewBox=\"0 0 1920 1280\">\n",
       "<defs>\n",
       "  <clipPath id=\"clip5500\">\n",
       "    <rect x=\"0\" y=\"0\" width=\"1920\" height=\"1280\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<path clip-path=\"url(#clip5500)\" d=\"\n",
       "M0 1280 L1920 1280 L1920 0 L0 0  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip5501\">\n",
       "    <rect x=\"384\" y=\"0\" width=\"1345\" height=\"1280\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<path clip-path=\"url(#clip5500)\" d=\"\n",
       "M243.864 1105.62 L1872.76 1105.62 L1872.76 121.675 L243.864 121.675  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip5502\">\n",
       "    <rect x=\"243\" y=\"121\" width=\"1630\" height=\"985\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  324.594,1105.62 324.594,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  569.166,1105.62 569.166,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  813.738,1105.62 813.738,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1058.31,1105.62 1058.31,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1302.88,1105.62 1302.88,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1547.45,1105.62 1547.45,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1792.03,1105.62 1792.03,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  243.864,1077.77 1872.76,1077.77 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  243.864,845.709 1872.76,845.709 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  243.864,613.647 1872.76,613.647 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  243.864,381.585 1872.76,381.585 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  243.864,149.523 1872.76,149.523 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  243.864,1105.62 1872.76,1105.62 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  243.864,1105.62 243.864,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  324.594,1105.62 324.594,1090.86 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  569.166,1105.62 569.166,1090.86 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  813.738,1105.62 813.738,1090.86 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1058.31,1105.62 1058.31,1090.86 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1302.88,1105.62 1302.88,1090.86 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1547.45,1105.62 1547.45,1090.86 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1792.03,1105.62 1792.03,1090.86 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  243.864,1077.77 268.298,1077.77 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  243.864,845.709 268.298,845.709 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  243.864,613.647 268.298,613.647 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  243.864,381.585 268.298,381.585 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5500)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  243.864,149.523 268.298,149.523 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 324.594, 1157.22)\" x=\"324.594\" y=\"1157.22\">-3</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 569.166, 1157.22)\" x=\"569.166\" y=\"1157.22\">-2</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 813.738, 1157.22)\" x=\"813.738\" y=\"1157.22\">-1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1058.31, 1157.22)\" x=\"1058.31\" y=\"1157.22\">0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1302.88, 1157.22)\" x=\"1302.88\" y=\"1157.22\">1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1547.45, 1157.22)\" x=\"1547.45\" y=\"1157.22\">2</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1792.03, 1157.22)\" x=\"1792.03\" y=\"1157.22\">3</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 224.664, 1095.27)\" x=\"224.664\" y=\"1095.27\">-1.0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 224.664, 863.209)\" x=\"224.664\" y=\"863.209\">-0.5</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 224.664, 631.147)\" x=\"224.664\" y=\"631.147\">0.0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 224.664, 399.085)\" x=\"224.664\" y=\"399.085\">0.5</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 224.664, 167.023)\" x=\"224.664\" y=\"167.023\">1.0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:84px; text-anchor:middle;\" transform=\"rotate(0, 1058.31, 73.2)\" x=\"1058.31\" y=\"73.2\">the sine function</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:66px; text-anchor:middle;\" transform=\"rotate(0, 1058.31, 1234.68)\" x=\"1058.31\" y=\"1234.68\">x</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5500)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:66px; text-anchor:middle;\" transform=\"rotate(-90, 98.8861, 613.647)\" x=\"98.8861\" y=\"613.647\">y</text>\n",
       "</g>\n",
       "<polyline clip-path=\"url(#clip5502)\" style=\"stroke:#ff0000; stroke-width:8; stroke-opacity:1; fill:none\" points=\"\n",
       "  289.965,613.647 305.332,642.789 320.699,671.817 336.066,700.615 351.432,729.07 366.799,757.069 382.166,784.502 397.533,811.261 412.9,837.24 428.267,862.337 \n",
       "  443.634,886.452 459.001,909.491 474.368,931.362 489.735,951.979 505.102,971.261 520.468,989.131 535.835,1005.52 551.202,1020.36 566.569,1033.6 581.936,1045.18 \n",
       "  597.303,1055.06 612.67,1063.19 628.037,1069.55 643.404,1074.11 658.771,1076.86 674.137,1077.77 689.504,1076.86 704.871,1074.11 720.238,1069.55 735.605,1063.19 \n",
       "  750.972,1055.06 766.339,1045.18 781.706,1033.6 797.073,1020.36 812.44,1005.52 827.806,989.131 843.173,971.261 858.54,951.979 873.907,931.362 889.274,909.491 \n",
       "  904.641,886.452 920.008,862.337 935.375,837.24 950.742,811.261 966.109,784.502 981.476,757.069 996.842,729.07 1012.21,700.615 1027.58,671.817 1042.94,642.789 \n",
       "  1058.31,613.647 1073.68,584.504 1089.04,555.477 1104.41,526.679 1119.78,498.224 1135.14,470.225 1150.51,442.791 1165.88,416.032 1181.25,390.053 1196.61,364.957 \n",
       "  1211.98,340.841 1227.35,317.803 1242.71,295.932 1258.08,275.315 1273.45,256.033 1288.81,238.162 1304.18,221.774 1319.55,206.932 1334.91,193.695 1350.28,182.115 \n",
       "  1365.65,172.238 1381.02,164.104 1396.38,157.744 1411.75,153.182 1427.12,150.438 1442.48,149.523 1457.85,150.438 1473.22,153.182 1488.58,157.744 1503.95,164.104 \n",
       "  1519.32,172.238 1534.68,182.115 1550.05,193.695 1565.42,206.932 1580.78,221.774 1596.15,238.162 1611.52,256.033 1626.89,275.315 1642.25,295.932 1657.62,317.803 \n",
       "  1672.99,340.841 1688.35,364.957 1703.72,390.053 1719.09,416.032 1734.45,442.791 1749.82,470.225 1765.19,498.224 1780.55,526.679 1795.92,555.477 1811.29,584.504 \n",
       "  1826.66,613.647 \n",
       "  \"/>\n",
       "</svg>\n"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xGrid = range(-pi,stop=pi,length=101)  #uniformly spaced grid\n",
    "yGrid = sin.(xGrid)                    #y values at xGrid \n",
    "\n",
    "plot( xGrid,yGrid,\n",
    "      linecolor = :red,\n",
    "      linewidth = 2,\n",
    "      legend = nothing,\n",
    "      title = \"the sine function\",\n",
    "      xlabel = \"x\",\n",
    "      ylabel = \"y\" )"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Interpolate\n",
    "\n",
    "The next cell calls on `CubicSplineInterpolation()` to create the \"look-up\" table (more precisely, create an interpolation object). \n",
    "\n",
    "To use a cubic spline it is required that the $x_i$ grid is *uniformly spaced* (for instance, 0.1,0.2,...). The case of a non-uniformly spaced $x$ grid is discussed later.\n",
    "\n",
    "The option `extrapolation_bc=...` determines how extrapolation beyond the range of the $x_i$ grid is done.\n",
    "\n",
    "The second cell interpolates and extrapolates $y$ at some specific $x$ values. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "itp = CubicSplineInterpolation(xGrid,yGrid,extrapolation_bc=Flat());"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x, interpolated y values and true y values\n",
      "     0.250     0.247     0.247\n",
      "     0.750     0.682     0.682\n",
      "\n",
      "x2 and extrapolated values\n",
      "     1.250     0.949\n",
      "     3.242     0.000\n",
      "     3.642     0.000\n",
      "\n"
     ]
    }
   ],
   "source": [
    "x  = [0.25,0.75]                     #to interpolate the y values at\n",
    "\n",
    "y_interpolated = itp(x) \n",
    "                         \n",
    "println(\"x, interpolated y values and true y values\")\n",
    "printmat([x y_interpolated sin.(x)])\n",
    "\n",
    "\n",
    "x2             = [1.25,pi+0.1,pi+0.5]            #to extrapolate the y values at\n",
    "y_extrapolated = itp(x2)                         #\"extrapolation\" can be done\n",
    "                                                 #inside and outside the range xGrid\n",
    "println(\"x2 and extrapolated values\")\n",
    "printmat([x2 y_extrapolated])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plotting the Results"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"480\" height=\"320\" viewBox=\"0 0 1920 1280\">\n",
       "<defs>\n",
       "  <clipPath id=\"clip5900\">\n",
       "    <rect x=\"0\" y=\"0\" width=\"1920\" height=\"1280\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<path clip-path=\"url(#clip5900)\" d=\"\n",
       "M0 1280 L1920 1280 L1920 0 L0 0  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip5901\">\n",
       "    <rect x=\"384\" y=\"0\" width=\"1345\" height=\"1280\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<path clip-path=\"url(#clip5900)\" d=\"\n",
       "M239.064 1108.82 L1872.76 1108.82 L1872.76 121.675 L239.064 121.675  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip5902\">\n",
       "    <rect x=\"239\" y=\"121\" width=\"1635\" height=\"988\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  317.472,1108.82 317.472,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  544.684,1108.82 544.684,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  771.895,1108.82 771.895,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  999.107,1108.82 999.107,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1226.32,1108.82 1226.32,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1453.53,1108.82 1453.53,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1680.74,1108.82 1680.74,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  239.064,1080.88 1872.76,1080.88 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  239.064,848.064 1872.76,848.064 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  239.064,615.247 1872.76,615.247 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  239.064,382.43 1872.76,382.43 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  239.064,149.613 1872.76,149.613 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  239.064,1108.82 1872.76,1108.82 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  239.064,1108.82 239.064,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  317.472,1108.82 317.472,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  544.684,1108.82 544.684,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  771.895,1108.82 771.895,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  999.107,1108.82 999.107,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1226.32,1108.82 1226.32,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1453.53,1108.82 1453.53,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1680.74,1108.82 1680.74,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  239.064,1080.88 263.57,1080.88 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  239.064,848.064 263.57,848.064 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  239.064,615.247 263.57,615.247 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  239.064,382.43 263.57,382.43 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  239.064,149.613 263.57,149.613 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 317.472, 1160.42)\" x=\"317.472\" y=\"1160.42\">-3</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 544.684, 1160.42)\" x=\"544.684\" y=\"1160.42\">-2</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 771.895, 1160.42)\" x=\"771.895\" y=\"1160.42\">-1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 999.107, 1160.42)\" x=\"999.107\" y=\"1160.42\">0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1226.32, 1160.42)\" x=\"1226.32\" y=\"1160.42\">1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1453.53, 1160.42)\" x=\"1453.53\" y=\"1160.42\">2</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1680.74, 1160.42)\" x=\"1680.74\" y=\"1160.42\">3</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 219.864, 1098.38)\" x=\"219.864\" y=\"1098.38\">-1.0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 219.864, 865.564)\" x=\"219.864\" y=\"865.564\">-0.5</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 219.864, 632.747)\" x=\"219.864\" y=\"632.747\">0.0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 219.864, 399.93)\" x=\"219.864\" y=\"399.93\">0.5</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 219.864, 167.113)\" x=\"219.864\" y=\"167.113\">1.0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:84px; text-anchor:middle;\" transform=\"rotate(0, 1055.91, 73.2)\" x=\"1055.91\" y=\"73.2\">the sine function</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:66px; text-anchor:middle;\" transform=\"rotate(0, 1055.91, 1237.88)\" x=\"1055.91\" y=\"1237.88\">x</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:66px; text-anchor:middle;\" transform=\"rotate(-90, 94.0861, 615.247)\" x=\"94.0861\" y=\"615.247\">y</text>\n",
       "</g>\n",
       "<polyline clip-path=\"url(#clip5902)\" style=\"stroke:#ff0000; stroke-width:8; stroke-opacity:1; fill:none\" points=\"\n",
       "  285.301,615.247 299.577,644.484 313.853,673.606 328.129,702.498 342.405,731.045 356.681,759.136 370.957,786.658 385.234,813.504 399.51,839.568 413.786,864.746 \n",
       "  428.062,888.94 442.338,912.053 456.614,933.995 470.89,954.679 485.167,974.024 499.443,991.952 513.719,1008.39 527.995,1023.28 542.271,1036.56 556.547,1048.18 \n",
       "  570.823,1058.09 585.099,1066.25 599.376,1072.63 613.652,1077.21 627.928,1079.96 642.204,1080.88 656.48,1079.96 670.756,1077.21 685.032,1072.63 699.308,1066.25 \n",
       "  713.585,1058.09 727.861,1048.18 742.137,1036.56 756.413,1023.28 770.689,1008.39 784.965,991.952 799.241,974.024 813.517,954.679 827.794,933.995 842.07,912.053 \n",
       "  856.346,888.94 870.622,864.746 884.898,839.568 899.174,813.504 913.45,786.658 927.726,759.136 942.003,731.045 956.279,702.498 970.555,673.606 984.831,644.484 \n",
       "  999.107,615.247 1013.38,586.009 1027.66,556.887 1041.94,527.996 1056.21,499.448 1070.49,471.358 1084.76,443.836 1099.04,416.99 1113.32,390.926 1127.59,365.748 \n",
       "  1141.87,341.554 1156.14,318.441 1170.42,296.499 1184.7,275.815 1198.97,256.47 1213.25,238.541 1227.53,222.099 1241.8,207.209 1256.08,193.929 1270.35,182.312 \n",
       "  1284.63,172.403 1298.91,164.242 1313.18,157.861 1327.46,153.285 1341.73,150.532 1356.01,149.613 1370.29,150.532 1384.56,153.285 1398.84,157.861 1413.11,164.242 \n",
       "  1427.39,172.403 1441.67,182.312 1455.94,193.929 1470.22,207.209 1484.5,222.099 1498.77,238.541 1513.05,256.47 1527.32,275.815 1541.6,296.499 1555.88,318.441 \n",
       "  1570.15,341.554 1584.43,365.748 1598.7,390.926 1612.98,416.99 1627.26,443.836 1641.53,471.358 1655.81,499.448 1670.09,527.996 1684.36,556.887 1698.64,586.009 \n",
       "  1712.91,615.247 \n",
       "  \"/>\n",
       "<polygon clip-path=\"url(#clip5902)\" style=\"fill:#000000; fill-opacity:1\" points=\"\n",
       "  1031.91,476.047 1031.91,524.047 1079.91,524.047 1079.91,476.047 1031.91,476.047 \n",
       "  \"/>\n",
       "<polygon clip-path=\"url(#clip5902)\" style=\"fill:#ff00ff; fill-opacity:1\" points=\"\n",
       "  1035.91,480.047 1035.91,520.047 1075.91,520.047 1075.91,480.047 1035.91,480.047 \n",
       "  \"/>\n",
       "<polygon clip-path=\"url(#clip5902)\" style=\"fill:#000000; fill-opacity:1\" points=\"\n",
       "  1145.52,273.853 1145.52,321.853 1193.52,321.853 1193.52,273.853 1145.52,273.853 \n",
       "  \"/>\n",
       "<polygon clip-path=\"url(#clip5902)\" style=\"fill:#ff00ff; fill-opacity:1\" points=\"\n",
       "  1149.52,277.853 1149.52,317.853 1189.52,317.853 1189.52,277.853 1149.52,277.853 \n",
       "  \"/>\n",
       "<circle clip-path=\"url(#clip5902)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1283.12\" cy=\"173.368\" r=\"32\"/>\n",
       "<circle clip-path=\"url(#clip5902)\" style=\"fill:#0000ff; stroke:none; fill-opacity:1\" cx=\"1283.12\" cy=\"173.368\" r=\"28\"/>\n",
       "<circle clip-path=\"url(#clip5902)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1735.63\" cy=\"615.247\" r=\"32\"/>\n",
       "<circle clip-path=\"url(#clip5902)\" style=\"fill:#0000ff; stroke:none; fill-opacity:1\" cx=\"1735.63\" cy=\"615.247\" r=\"28\"/>\n",
       "<circle clip-path=\"url(#clip5902)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1826.52\" cy=\"615.247\" r=\"32\"/>\n",
       "<circle clip-path=\"url(#clip5902)\" style=\"fill:#0000ff; stroke:none; fill-opacity:1\" cx=\"1826.52\" cy=\"615.247\" r=\"28\"/>\n",
       "<path clip-path=\"url(#clip5900)\" d=\"\n",
       "M1352.93 418.315 L1815.16 418.315 L1815.16 176.395 L1352.93 176.395  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1352.93,418.315 1815.16,418.315 1815.16,176.395 1352.93,176.395 1352.93,418.315 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip5900)\" style=\"stroke:#ff0000; stroke-width:8; stroke-opacity:1; fill:none\" points=\"\n",
       "  1372.13,236.875 1487.33,236.875 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 1506.53, 254.375)\" x=\"1506.53\" y=\"254.375\">sine function</text>\n",
       "</g>\n",
       "<polygon clip-path=\"url(#clip5900)\" style=\"fill:#000000; fill-opacity:1\" points=\"\n",
       "  1411.33,269.355 1411.33,325.355 1467.33,325.355 1467.33,269.355 1411.33,269.355 \n",
       "  \"/>\n",
       "<polygon clip-path=\"url(#clip5900)\" style=\"fill:#ff00ff; fill-opacity:1\" points=\"\n",
       "  1415.33,273.355 1415.33,321.355 1463.33,321.355 1463.33,273.355 1415.33,273.355 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 1506.53, 314.855)\" x=\"1506.53\" y=\"314.855\">interpolated</text>\n",
       "</g>\n",
       "<circle clip-path=\"url(#clip5900)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1439.33\" cy=\"357.835\" r=\"25\"/>\n",
       "<circle clip-path=\"url(#clip5900)\" style=\"fill:#0000ff; stroke:none; fill-opacity:1\" cx=\"1439.33\" cy=\"357.835\" r=\"21\"/>\n",
       "<g clip-path=\"url(#clip5900)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:start;\" transform=\"rotate(0, 1506.53, 375.335)\" x=\"1506.53\" y=\"375.335\">extrapolated</text>\n",
       "</g>\n",
       "</svg>\n"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plot( xGrid,yGrid,\n",
    "      linecolor = :red,\n",
    "      linewidth = 2,\n",
    "      label = \"sine function\",\n",
    "      title = \"the sine function\",\n",
    "      xlabel = \"x\",\n",
    "      ylabel = \"y\" )    \n",
    "    \n",
    "scatter!(x,y_interpolated,markercolor=:magenta,markersize=5,marker=:square,label=\"interpolated\")\n",
    "scatter!(x2,y_extrapolated,markercolor=:blue,markersize=8,label=\"extrapolated\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Interpolation of y = f(x) for General Vectors\n",
    "\n",
    "That is, when we cannot guarantee that the look-up table of $y_i=f(x_i)$ is from uniformly spaced $x_i$ values. This is useful, for instance, when we have empirical data on $(x_i,y_i)$.\n",
    "\n",
    "The approach works similar to before, except that the `CubicSplineInterpolation` must be replaced by `LinearInterpolation`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
       "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"480\" height=\"320\" viewBox=\"0 0 1920 1280\">\n",
       "<defs>\n",
       "  <clipPath id=\"clip6300\">\n",
       "    <rect x=\"0\" y=\"0\" width=\"1920\" height=\"1280\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<path clip-path=\"url(#clip6300)\" d=\"\n",
       "M0 1280 L1920 1280 L1920 0 L0 0  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip6301\">\n",
       "    <rect x=\"384\" y=\"0\" width=\"1345\" height=\"1280\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<path clip-path=\"url(#clip6300)\" d=\"\n",
       "M177.208 1108.82 L1872.76 1108.82 L1872.76 121.675 L177.208 121.675  Z\n",
       "  \" fill=\"#ffffff\" fill-rule=\"evenodd\" fill-opacity=\"1\"/>\n",
       "<defs>\n",
       "  <clipPath id=\"clip6302\">\n",
       "    <rect x=\"177\" y=\"121\" width=\"1697\" height=\"988\"/>\n",
       "  </clipPath>\n",
       "</defs>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  261.242,1108.82 261.242,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  515.822,1108.82 515.822,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  770.402,1108.82 770.402,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1024.98,1108.82 1024.98,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1279.56,1108.82 1279.56,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1534.14,1108.82 1534.14,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  1788.72,1108.82 1788.72,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  177.208,1080.88 1872.76,1080.88 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  177.208,848.064 1872.76,848.064 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  177.208,615.247 1872.76,615.247 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  177.208,382.43 1872.76,382.43 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6302)\" style=\"stroke:#000000; stroke-width:2; stroke-opacity:0.1; fill:none\" points=\"\n",
       "  177.208,149.613 1872.76,149.613 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  177.208,1108.82 1872.76,1108.82 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  177.208,1108.82 177.208,121.675 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  261.242,1108.82 261.242,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  515.822,1108.82 515.822,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  770.402,1108.82 770.402,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1024.98,1108.82 1024.98,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1279.56,1108.82 1279.56,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1534.14,1108.82 1534.14,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  1788.72,1108.82 1788.72,1094.01 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  177.208,1080.88 202.641,1080.88 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  177.208,848.064 202.641,848.064 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  177.208,615.247 202.641,615.247 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  177.208,382.43 202.641,382.43 \n",
       "  \"/>\n",
       "<polyline clip-path=\"url(#clip6300)\" style=\"stroke:#000000; stroke-width:4; stroke-opacity:1; fill:none\" points=\"\n",
       "  177.208,149.613 202.641,149.613 \n",
       "  \"/>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 261.242, 1160.42)\" x=\"261.242\" y=\"1160.42\">-3</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 515.822, 1160.42)\" x=\"515.822\" y=\"1160.42\">-2</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 770.402, 1160.42)\" x=\"770.402\" y=\"1160.42\">-1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1024.98, 1160.42)\" x=\"1024.98\" y=\"1160.42\">0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1279.56, 1160.42)\" x=\"1279.56\" y=\"1160.42\">1</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1534.14, 1160.42)\" x=\"1534.14\" y=\"1160.42\">2</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:middle;\" transform=\"rotate(0, 1788.72, 1160.42)\" x=\"1788.72\" y=\"1160.42\">3</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 158.008, 1098.38)\" x=\"158.008\" y=\"1098.38\">-1.0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 158.008, 865.564)\" x=\"158.008\" y=\"865.564\">-0.5</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 158.008, 632.747)\" x=\"158.008\" y=\"632.747\">0.0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 158.008, 399.93)\" x=\"158.008\" y=\"399.93\">0.5</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:48px; text-anchor:end;\" transform=\"rotate(0, 158.008, 167.113)\" x=\"158.008\" y=\"167.113\">1.0</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:84px; text-anchor:middle;\" transform=\"rotate(0, 1024.98, 73.2)\" x=\"1024.98\" y=\"73.2\">y</text>\n",
       "</g>\n",
       "<g clip-path=\"url(#clip6300)\">\n",
       "<text style=\"fill:#000000; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:66px; text-anchor:middle;\" transform=\"rotate(0, 1024.98, 1237.88)\" x=\"1024.98\" y=\"1237.88\">x</text>\n",
       "</g>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"225.195\" cy=\"615.247\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"225.195\" cy=\"615.247\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"241.191\" cy=\"644.484\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"241.191\" cy=\"644.484\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"257.187\" cy=\"673.606\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"257.187\" cy=\"673.606\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"273.182\" cy=\"702.498\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"273.182\" cy=\"702.498\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"289.178\" cy=\"731.045\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"289.178\" cy=\"731.045\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"305.174\" cy=\"759.136\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"305.174\" cy=\"759.136\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"321.17\" cy=\"786.658\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"321.17\" cy=\"786.658\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"337.165\" cy=\"813.504\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"337.165\" cy=\"813.504\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"353.161\" cy=\"839.568\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"353.161\" cy=\"839.568\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"369.157\" cy=\"864.746\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"369.157\" cy=\"864.746\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"385.153\" cy=\"888.94\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"385.153\" cy=\"888.94\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"401.148\" cy=\"912.053\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"401.148\" cy=\"912.053\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"417.144\" cy=\"933.995\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"417.144\" cy=\"933.995\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"433.14\" cy=\"954.679\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"433.14\" cy=\"954.679\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"449.136\" cy=\"974.024\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"449.136\" cy=\"974.024\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"465.131\" cy=\"991.952\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"465.131\" cy=\"991.952\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"481.127\" cy=\"1008.39\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"481.127\" cy=\"1008.39\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"497.123\" cy=\"1023.28\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"497.123\" cy=\"1023.28\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"513.118\" cy=\"1036.56\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"513.118\" cy=\"1036.56\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"529.114\" cy=\"1048.18\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"529.114\" cy=\"1048.18\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"545.11\" cy=\"1058.09\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"545.11\" cy=\"1058.09\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"561.106\" cy=\"1066.25\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"561.106\" cy=\"1066.25\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"577.101\" cy=\"1072.63\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"577.101\" cy=\"1072.63\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"593.097\" cy=\"1077.21\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"593.097\" cy=\"1077.21\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"609.093\" cy=\"1079.96\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"609.093\" cy=\"1079.96\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"625.089\" cy=\"1080.88\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"625.089\" cy=\"1080.88\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"641.084\" cy=\"1079.96\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"641.084\" cy=\"1079.96\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"657.08\" cy=\"1077.21\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"657.08\" cy=\"1077.21\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"673.076\" cy=\"1072.63\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"673.076\" cy=\"1072.63\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"689.072\" cy=\"1066.25\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"689.072\" cy=\"1066.25\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"705.067\" cy=\"1058.09\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"705.067\" cy=\"1058.09\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"721.063\" cy=\"1048.18\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"721.063\" cy=\"1048.18\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"737.059\" cy=\"1036.56\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"737.059\" cy=\"1036.56\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"753.054\" cy=\"1023.28\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"753.054\" cy=\"1023.28\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"769.05\" cy=\"1008.39\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"769.05\" cy=\"1008.39\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"785.046\" cy=\"991.952\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"785.046\" cy=\"991.952\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"801.042\" cy=\"974.024\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"801.042\" cy=\"974.024\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"817.037\" cy=\"954.679\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"817.037\" cy=\"954.679\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"833.033\" cy=\"933.995\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"833.033\" cy=\"933.995\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"849.029\" cy=\"912.053\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"849.029\" cy=\"912.053\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"865.025\" cy=\"888.94\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"865.025\" cy=\"888.94\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"881.02\" cy=\"864.746\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"881.02\" cy=\"864.746\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"897.016\" cy=\"839.568\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"897.016\" cy=\"839.568\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"913.012\" cy=\"813.504\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"913.012\" cy=\"813.504\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"929.008\" cy=\"786.658\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"929.008\" cy=\"786.658\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"945.003\" cy=\"759.136\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"945.003\" cy=\"759.136\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"960.999\" cy=\"731.045\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"960.999\" cy=\"731.045\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"976.995\" cy=\"702.498\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"976.995\" cy=\"702.498\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"992.991\" cy=\"673.606\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"992.991\" cy=\"673.606\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1008.99\" cy=\"644.484\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1008.99\" cy=\"644.484\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1024.98\" cy=\"615.247\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1024.98\" cy=\"615.247\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1040.98\" cy=\"586.009\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1040.98\" cy=\"586.009\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1056.97\" cy=\"556.887\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1056.97\" cy=\"556.887\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1072.97\" cy=\"527.996\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1072.97\" cy=\"527.996\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1184.94\" cy=\"341.554\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1184.94\" cy=\"341.554\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1200.94\" cy=\"318.441\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1200.94\" cy=\"318.441\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1216.93\" cy=\"296.499\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1216.93\" cy=\"296.499\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1232.93\" cy=\"275.815\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1232.93\" cy=\"275.815\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1248.92\" cy=\"256.47\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1248.92\" cy=\"256.47\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1264.92\" cy=\"238.541\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1264.92\" cy=\"238.541\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1280.91\" cy=\"222.099\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1280.91\" cy=\"222.099\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1296.91\" cy=\"207.209\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1296.91\" cy=\"207.209\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1312.91\" cy=\"193.929\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1312.91\" cy=\"193.929\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1328.9\" cy=\"182.312\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1328.9\" cy=\"182.312\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1344.9\" cy=\"172.403\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1344.9\" cy=\"172.403\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1360.89\" cy=\"164.242\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1360.89\" cy=\"164.242\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1376.89\" cy=\"157.861\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1376.89\" cy=\"157.861\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1392.88\" cy=\"153.285\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1392.88\" cy=\"153.285\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1408.88\" cy=\"150.532\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1408.88\" cy=\"150.532\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1424.88\" cy=\"149.613\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1424.88\" cy=\"149.613\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1440.87\" cy=\"150.532\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1440.87\" cy=\"150.532\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1456.87\" cy=\"153.285\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1456.87\" cy=\"153.285\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1472.86\" cy=\"157.861\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1472.86\" cy=\"157.861\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1488.86\" cy=\"164.242\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1488.86\" cy=\"164.242\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1504.85\" cy=\"172.403\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1504.85\" cy=\"172.403\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1520.85\" cy=\"182.312\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1520.85\" cy=\"182.312\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1536.85\" cy=\"193.929\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1536.85\" cy=\"193.929\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1552.84\" cy=\"207.209\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1552.84\" cy=\"207.209\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1568.84\" cy=\"222.099\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1568.84\" cy=\"222.099\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1584.83\" cy=\"238.541\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1584.83\" cy=\"238.541\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1600.83\" cy=\"256.47\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1600.83\" cy=\"256.47\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1616.82\" cy=\"275.815\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1616.82\" cy=\"275.815\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1632.82\" cy=\"296.499\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1632.82\" cy=\"296.499\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1648.82\" cy=\"318.441\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1648.82\" cy=\"318.441\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1664.81\" cy=\"341.554\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1664.81\" cy=\"341.554\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1680.81\" cy=\"365.748\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1680.81\" cy=\"365.748\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1696.8\" cy=\"390.926\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1696.8\" cy=\"390.926\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1712.8\" cy=\"416.99\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1712.8\" cy=\"416.99\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1728.79\" cy=\"443.836\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1728.79\" cy=\"443.836\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1744.79\" cy=\"471.358\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1744.79\" cy=\"471.358\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1760.79\" cy=\"499.448\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1760.79\" cy=\"499.448\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1776.78\" cy=\"527.996\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1776.78\" cy=\"527.996\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1792.78\" cy=\"556.887\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1792.78\" cy=\"556.887\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1808.77\" cy=\"586.009\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1808.77\" cy=\"586.009\" r=\"14\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#000000; stroke:none; fill-opacity:1\" cx=\"1824.77\" cy=\"615.247\" r=\"18\"/>\n",
       "<circle clip-path=\"url(#clip6302)\" style=\"fill:#009af9; stroke:none; fill-opacity:1\" cx=\"1824.77\" cy=\"615.247\" r=\"14\"/>\n",
       "</svg>\n"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xGrid2 = deleteat!(collect(xGrid),55:60)         #non-uniformly spaced grid     \n",
    "yGrid2 = sin.(xGrid2)\n",
    "\n",
    "scatter( xGrid2,yGrid2,\n",
    "         linecolor = :red,\n",
    "         legend = false,\n",
    "         title = \"y\",\n",
    "         xlabel = \"x\" )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x, interpolated y values and true y values\n",
      "     0.250     0.243     0.247\n",
      "     0.750     0.682     0.682\n",
      "\n",
      "x2 and extrapolated values\n",
      "     1.250     0.949\n",
      "     3.242     0.000\n",
      "     3.642     0.000\n",
      "\n"
     ]
    }
   ],
   "source": [
    "itp2 = LinearInterpolation(xGrid2,yGrid2,extrapolation_bc=Flat()) \n",
    "                                           \n",
    "y_interpolated = itp2(x) \n",
    "                         \n",
    "println(\"x, interpolated y values and true y values\")\n",
    "printmat([x y_interpolated sin.(x)])\n",
    "\n",
    "y_extrapolated = itp2(x2)   \n",
    "                            \n",
    "println(\"x2 and extrapolated values\")\n",
    "printmat([x2 y_extrapolated])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "@webio": {
   "lastCommId": null,
   "lastKernelId": null
  },
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Julia 1.3.0",
   "language": "julia",
   "name": "julia-1.3"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "1.3.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
